package com.haiyou.dc.mybatis.mapper;

import com.haiyou.common.base.BaseMapper;
import com.haiyou.dc.mybatis.entity.MybatisUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;

/**
 * @author root
 * @date 2020-01-30 12:07:06
 */
@Mapper
public interface MybatisUserMapper extends BaseMapper<MybatisUser> {

    /**
     * 代码写在xml里面报错，用注解没有问题
     */

    /**
     * ---------------------------------------------
     * <p>
     * /**
     * 增加用户
     *
     * @param user
     */
    @Select("{call insert_user( #{id,mode=OUT,jdbcType=INTEGER},#{name,mode=IN},#{sex,mode=IN},#{age,mode=IN})}")
    @Options(statementType = StatementType.CALLABLE)
    void addUser(MybatisUser user);

    /**
     * 删除用户
     *
     * @param id
     */
    @Select("{call delete_user(#{id,mode=IN})}")
    @Options(statementType = StatementType.CALLABLE)
    void deleteUser(Integer id);

    /**
     * 根据id查询用户
     *
     * @param id
     * @return
     */
    @Select("{call getUserById(#{id,mode=IN})}")
    @Options(statementType = StatementType.CALLABLE)
    MybatisUser getUserById(Integer id);

    /**
     * 更新用户
     *
     * @param user
     */
    void updateUser(MybatisUser user);

}